import Vue from "vue"
import App from "./App.vue"
import kityminder from "./index"
import router from "./router"
import  elementUI from "element-ui"
import locale from 'element-ui/lib/locale/lang/en'
import "element-ui/lib/theme-chalk/index.css";
import  axios from 'axios'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import VueCookies from 'vue-cookies'

import _global from '../static/permission.js';
Vue.prototype.$global = _global;


Vue.use(VXETable)
Vue.use(kityminder)
Vue.use(elementUI,{ locale })
Vue.config.productionTip = false
Vue.prototype.$cookies=VueCookies;
Vue.prototype.$axios = axios


axios.interceptors.response.use(
    res => { // 全局接口响应拦截
      if(res.data !=null && res.data.code ==401 ){ // 登录失效时重定向
        router.replace('/login');
      }
      return  res
    }
    ,error => {
      if(error.response.status==401 ){ // 登录失效时重定向
        router.replace('/login');
      }
    }
);

//禁止浏览器前进后退，不然会导致甘道图无法左右滑动
window.addEventListener('popstate', function() {
    history.pushState(null, null, document.URL)
})


new Vue({
  router,
  render: h => h(App)
}).$mount("#app")
